import React, {useState, useRef} from 'react';
import {View, Easing} from 'react-native';
import ModalBox from "./ModalBox";


export default class PresentView extends React.PureComponent{
  constructor(props){
    super(props);
    this.state = {height: 100};
  }
  open = ()=>{
    this.refs.modal.open();
  };
  close = ()=>{
    this.refs.modal.close();
  };
  render(){
    return <ModalBox
      position={"bottom"}
      ref={"modal"}
      style={{height:this.state.height}}
      animationDuration={200}
      backButtonClose={true}
      swipeToClose={false}
      backdropPressToClose={true}
      easing={Easing.elastic(1)}
    >
      <View style={{alignSelf:'stretch'}}
            onLayout={(event)=>{
              let {height} = event.nativeEvent.layout;
              this.setState({height});
            }}
      >
        {this.props.children}
      </View>
    </ModalBox>;
  }
};
